#include "IpcMqttClientPublish.h"
#include "OSC_cJSON.h"
#include "IpcMqttClient.h"
#include "IpcMqttCommon.h"
#include "InComTimer.h"

#define DEF_TAG             "IpcMqttClientP"

Com_u32 g_IpcMqttClientPublish_MsgID = 0;

// 属性Topic内容
Com_s32 IpcMqttClientPublish_MsgPack(OSC_cJSON *json_buf,pStIpcMqttComPublishInfo p_info)
{
    ComNullRetInt(p_info->Cmd);

    if (p_info->MsgID == NULL)
    {
        char MsgID_buf[32];
        memset(MsgID_buf,0,sizeof(MsgID_buf));

        g_IpcMqttClientPublish_MsgID++;
        sprintf(MsgID_buf,"%d",g_IpcMqttClientPublish_MsgID);
        OSC_cJSON_AddStringToObject(json_buf, "MsgID",MsgID_buf);
    }
    else
    {
        OSC_cJSON_AddStringToObject(json_buf, "MsgID",p_info->MsgID);
    }

    OSC_cJSON_AddNumberToObject(json_buf, "DevChn",p_info->DevChn);

    Com_s8 Time_buf[40];
    memset(Time_buf,0,sizeof(Time_buf));
    Ext_InComTimer_GetTimeStr(Time_buf);
    OSC_cJSON_AddStringToObject(json_buf, "Time",Time_buf);
    OSC_cJSON_AddStringToObject(json_buf, "Cmd",p_info->Cmd);

    if(p_info->Data->type != OSC_cJSON_Object)
    {
        OSC_cJSON_AddStringToObject(json_buf, "Data","{}");
    }
    else
    {
        OSC_cJSON_AddItemToObject(json_buf, "Data", p_info->Data);
    }

    return DEF_COM_SUCCESS;
}

Com_void Ext_IpcMqttClientPublish_Msg(pStIpcMqttComPublishInfo p_info,Com_s32 topic)
{
    Com_s32 ret;
    Com_ps8 p_buf;
    mqtt_message_t msg;

    memset(&msg, 0, sizeof(msg));

    OSC_cJSON *json_buf = OSC_cJSON_CreateObject();

    ret = IpcMqttClientPublish_MsgPack(json_buf,p_info);
    if(ret != DEF_COM_SUCCESS)
    {
        PRT_ERR(DEF_TAG,"Property pack error\n");
        OSC_cJSON_Delete(json_buf);
        return;
    }

    p_buf = OSC_cJSON_PrintUnformatted(json_buf);
    msg.payload = (void *)p_buf;
    msg.qos = p_info->qos;

    switch (topic)
    {
    case IPC_MQTT_COM_TOPIC_PROPERTY_POST:
        PRT_INFO(DEF_TAG, "property/post \n%s\n", (Com_ps8)msg.payload);
        break;

    case IPC_MQTT_COM_TOPIC_SERVICE_POST:
        PRT_INFO(DEF_TAG, "service/post \n%s\n", (Com_ps8)msg.payload);
        break;

    case IPC_MQTT_COM_TOPIC_EVENT_POST:
        PRT_INFO(DEF_TAG, "event/post \n%s\n", (Com_ps8)msg.payload);
        break;

    default:
        break;
    }
    mqtt_publish(p_info->client, Ext_Get_g_IpcMqttTopic_Info(topic), &msg);

    OSC_cJSON_Delete(json_buf);
    free(p_buf);
}

Com_void IpcMqttClientPublish_PropertyPostVerInfo(OSC_cJSON *json_buf)
{
    StIpcMqttPostVerInfo info;
    memset(&info,0,sizeof(info));

    strcpy(info.BottomVer,"1.0");
    OSC_cJSON_AddStringToObject(json_buf, "BottomVer",info.BottomVer);

    strcpy(info.PtzVer,"1.0");
    OSC_cJSON_AddStringToObject(json_buf, "PtzVer",info.PtzVer);

    strcpy(info.McuVer,"1.0");
    OSC_cJSON_AddStringToObject(json_buf, "McuVer",info.McuVer);
}

Com_void Ext_IpcMqttClientPublish_PropertyDevInfo(OSC_cJSON *json_buf)
{
    StIpcMqttDevInfo info;
    memset(&info,0,sizeof(info));

    strcpy(info.ProductID,"ZKKC");
    OSC_cJSON_AddStringToObject(json_buf, "ProductID",info.ProductID);

    strcpy(info.DeviceNum,"ABC123456");
    OSC_cJSON_AddStringToObject(json_buf, "DeviceNum",info.DeviceNum);

    strcpy(info.ProductType,"IC01");
    OSC_cJSON_AddStringToObject(json_buf, "ProductType",info.ProductType);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode",0);
}

Com_void Ext_IpcMqttClientPublish_PropertyNetInfo(OSC_cJSON *json_buf)
{
    StIpcMqttNetInfo info;
    memset(&info,0,sizeof(info));

    info.DHCPMode = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "DHCPMode",info.DHCPMode);

    strcpy(info.DevIP,"192.168.1.100");
    OSC_cJSON_AddStringToObject(json_buf, "DevIP",info.DevIP);

    strcpy(info.Netmask,"255.255.255.0");
    OSC_cJSON_AddStringToObject(json_buf, "Netmask",info.Netmask);

    strcpy(info.Gateway,"192.168.1.1");
    OSC_cJSON_AddStringToObject(json_buf, "Gateway",info.Gateway);

    strcpy(info.ServerIP,"192.168.1.88");
    OSC_cJSON_AddStringToObject(json_buf, "ServerIP",info.ServerIP);

    info.Port = 1883;
    OSC_cJSON_AddNumberToObject(json_buf, "Port",info.Port);

    info.S_4G = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "S_4G",info.S_4G);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode",0);
}

Com_void Ext_IpcMqttClientPublish_PropertyDevTime(OSC_cJSON *json_buf)
{
    OSC_cJSON_AddStringToObject(json_buf, "Date","2025-08-07 11:38:18");
    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode",0);
}

Com_void Ext_IpcMqttClientPublish_PropertyVideoEncode(OSC_cJSON *json_buf)
{
    StIpcMqttVideoEncode info;
    memset(&info,0,sizeof(info));

    strcpy(info.Resolution,"1920x1080");
    OSC_cJSON_AddStringToObject(json_buf, "Resolution",info.Resolution);

    info.Fps = 15;
    OSC_cJSON_AddNumberToObject(json_buf, "Fps",info.Fps);

    info.Gop = 30;
    OSC_cJSON_AddNumberToObject(json_buf, "Gop",info.Gop);

    info.Encode = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Encode",info.Encode);

    info.RcMode = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "RcMode",info.RcMode);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode",0);
}

Com_void Ext_IpcMqttClientPublish_PropertyIspParam(OSC_cJSON *json_buf)
{
    StIpcMqttIspParam info;
    memset(&info,0,sizeof(info));

    info.ColorMode = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "ColorMode",info.ColorMode);

    info.Luma = 50;
    OSC_cJSON_AddNumberToObject(json_buf, "Luma",info.Luma);

    info.Contrast = 50;
    OSC_cJSON_AddNumberToObject(json_buf, "Contrast",info.Contrast);

    info.Saturation = 50;
    OSC_cJSON_AddNumberToObject(json_buf, "Saturation",info.Saturation);

    info.GainCtrl = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "GainCtrl",info.GainCtrl);

    info.Denoise = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Denoise",info.Denoise);

    info.WB = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "WB", info.WB);

    info.DEFOG = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "DEFOG", info.DEFOG);

    info.BLC = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "BLC", info.BLC);

    info.Dynamic = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Dynamic", info.Dynamic);

    info.HSBLC = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "HSBLC", info.HSBLC);

    info.VideoMode = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "VideoMode", info.VideoMode);

    strcpy(info.NightModeTime, "64800-28800");
    OSC_cJSON_AddStringToObject(json_buf, "NightModeTime", info.NightModeTime);

    info.Focus = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Focus", info.Focus);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode",0);
}

Com_void Ext_IpcMqttClientPublish_PropertyRecordChn(OSC_cJSON *json_buf)
{
    OSC_cJSON_AddNumberToObject(json_buf, "RecordChn",0);
    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode",0);
}

Com_void Ext_IpcMqttClientPublish_PropertyOSDMode(OSC_cJSON *json_buf)
{
    StIpcMqttOSDMode info;
    memset(&info,0,sizeof(info));

    info.Position = 1;
    OSC_cJSON_AddNumberToObject(json_buf, "Position", info.Position);

    info.TimeShow = 1;
    OSC_cJSON_AddNumberToObject(json_buf, "TimeShow", info.TimeShow);

    info.VoltageShow = 1;
    OSC_cJSON_AddNumberToObject(json_buf, "VoltageShow", info.VoltageShow);

    strcpy(info.VoltageInfo, "18V");
    OSC_cJSON_AddStringToObject(json_buf, "VoltageInfo", info.VoltageInfo);

    info.BDShow = 1;
    OSC_cJSON_AddNumberToObject(json_buf, "BDShow", info.BDShow);

    strcpy(info.BDInfo, "BDS0.0,0.0");
    OSC_cJSON_AddStringToObject(json_buf, "BDInfo", info.BDInfo);

    info.MicroclimateShow = 1;
    OSC_cJSON_AddNumberToObject(json_buf, "MicroclimateShow", info.MicroclimateShow);

    strcpy(info.HumitureInfo, "湿度57.9% 温度27.7C");
    OSC_cJSON_AddStringToObject(json_buf, "HumitureInfo", info.HumitureInfo);

    strcpy(info.WDIRInfo, "风速0.57ms 东风");
    OSC_cJSON_AddStringToObject(json_buf, "WDIRInfo", info.WDIRInfo);

    strcpy(info.AirPressureInfo, "气压1005.03hPa");
    OSC_cJSON_AddStringToObject(json_buf, "AirPressureInfo", info.AirPressureInfo);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode", 0);
}

Com_void Ext_IpcMqttClientPublish_PropertyCustomOSD(OSC_cJSON *json_buf)
{
    StIpcMqttCustomOSD info;
    StIpcMqttOsdCustomInfo c_info[4];

    memset(&info,0,sizeof(info));
    memset(&c_info,0,sizeof(c_info));

    info.Position = 3;
    OSC_cJSON_AddNumberToObject(json_buf, "Position",info.Position);

    info.ChnNameShow = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "ChnNameShow",info.ChnNameShow);

    strcpy(info.ChnNameInfo, "IPCam");
    OSC_cJSON_AddStringToObject(json_buf, "ChnNameInfo",info.ChnNameInfo);

    OSC_cJSON *json_array = OSC_cJSON_CreateArray();
    OSC_cJSON *CustomInfo = OSC_cJSON_CreateObject();

    info.CustomInfo = c_info;
    info.CustomInfo[0].StrShow = 0;
    OSC_cJSON_AddNumberToObject(CustomInfo, "StrShow", info.CustomInfo[0].StrShow);

    strcpy(info.CustomInfo[0].StrInfo, "ZKKC");
    OSC_cJSON_AddStringToObject(CustomInfo, "StrInfo", info.CustomInfo[0].StrInfo);
    OSC_cJSON_AddItemToArray(json_array,CustomInfo);
    OSC_cJSON_AddItemToObject(json_buf, "CustomInfo", json_array);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode", 0);
}

Com_void Ext_IpcMqttClientPublish_PropertyGB28181Param(OSC_cJSON *json_buf)
{
    StIpcMqttGB28181Param info;
    memset(&info,0,sizeof(info));

    info.Status = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Status", info.Status);

    strcpy(info.ServerIP, "120.79.132.29");
    OSC_cJSON_AddStringToObject(json_buf, "ServerIP", info.ServerIP);

    info.Port = 5060;
    OSC_cJSON_AddNumberToObject(json_buf, "Port", info.Port);

    strcpy(info.SIPID, "34020000002000000001");
    OSC_cJSON_AddStringToObject(json_buf, "SIPID", info.SIPID);

    strcpy(info.SIPDomain, "3402000000");
    OSC_cJSON_AddStringToObject(json_buf, "SIPDomain", info.SIPDomain);

    strcpy(info.DevID, "34020000001110000001");
    OSC_cJSON_AddStringToObject(json_buf, "DevID", info.DevID);

    strcpy(info.DevName, "admin");
    OSC_cJSON_AddStringToObject(json_buf, "DevName", info.DevName);

    strcpy(info.Password, "admin");
    OSC_cJSON_AddStringToObject(json_buf, "Password", info.Password);

    info.Protocol = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Protocol", info.Protocol);

    info.RegExpires = 3600;
    OSC_cJSON_AddNumberToObject(json_buf, "RegExpires", info.RegExpires);

    info.Heartbeat = 30;
    OSC_cJSON_AddNumberToObject(json_buf, "Heartbeat", info.Heartbeat);

    info.HeartbeatCnt = 3;
    OSC_cJSON_AddNumberToObject(json_buf, "HeartbeatCnt", info.HeartbeatCnt);

    strcpy(info.Cid, "34020000001310000001");
    OSC_cJSON_AddStringToObject(json_buf, "Cid", info.Cid);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode", 0);
}

Com_void Ext_IpcMqttClientPublish_PropertyCruiseData(OSC_cJSON *json_buf,Com_s32 index)
{
    StIpcMqttCruiseData info;
    StIpcMqttCruiseInfo c_info;

    memset(&info,0,sizeof(info));
    memset(&c_info,0,sizeof(c_info));

    info.CruiseIndex = index;
    OSC_cJSON_AddNumberToObject(json_buf, "CruiseIndex",info.CruiseIndex);

    info.CruiseFlag = 1;
    OSC_cJSON_AddNumberToObject(json_buf, "CruiseFlag",info.CruiseFlag);

    OSC_cJSON *json_array = OSC_cJSON_CreateArray();
    OSC_cJSON *CruiseInfo = OSC_cJSON_CreateObject();

    info.CruiseInfo = &c_info;
    info.CruiseInfo->CruisePointFlag = 1;
    OSC_cJSON_AddNumberToObject(CruiseInfo, "CruisePointFlag", info.CruiseInfo->CruisePointFlag);

    info.CruiseInfo->CruisePreset = 1;
    OSC_cJSON_AddNumberToObject(CruiseInfo, "CruisePreset", info.CruiseInfo->CruisePreset);

    info.CruiseInfo->CruiseSpeed = 1;
    OSC_cJSON_AddNumberToObject(CruiseInfo, "CruiseSpeed", info.CruiseInfo->CruiseSpeed);

    info.CruiseInfo->CruiseTime = 1;
    OSC_cJSON_AddNumberToObject(CruiseInfo, "CruiseTime", info.CruiseInfo->CruiseTime);

    OSC_cJSON_AddItemToArray(json_array, CruiseInfo);
    OSC_cJSON_AddItemToObject(json_buf, "CruiseInfo", json_array);

    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode", 0);
}

Com_void IpcMqttClientPublish_PropertyPostTFInfo(OSC_cJSON *json_buf)
{
    StIpcMqttPostTFInfo info;
    memset(&info, 0, sizeof(info));

    info.Total = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "Total", info.Total);

    info.FreeSpace = 0;
    OSC_cJSON_AddNumberToObject(json_buf, "FreeSpace", info.FreeSpace);
}

Com_void Ext_IpcMqttClientPublish_PropertyTimingSnapshot(OSC_cJSON *json_buf)
{
    StIpcMqttTimingSnapshot info;
    StIpcMqttTimingInfo t_info;

    memset(&info, 0, sizeof(info));
    memset(&t_info, 0, sizeof(t_info));

    OSC_cJSON *json_array = OSC_cJSON_CreateArray();
    OSC_cJSON *TimingInfo = OSC_cJSON_CreateObject();

    info.TimingInfo = &t_info;

    info.TimingInfo->Hour = 0;
    OSC_cJSON_AddNumberToObject(TimingInfo, "Hour", info.TimingInfo->Hour);

    info.TimingInfo->Minute = 0;
    OSC_cJSON_AddNumberToObject(TimingInfo, "Minute", info.TimingInfo->Minute);

    info.TimingInfo->PresetNum = 0;
    OSC_cJSON_AddNumberToObject(TimingInfo, "PresetNum", info.TimingInfo->PresetNum);

    OSC_cJSON_AddItemToArray(json_array,TimingInfo);
    OSC_cJSON_AddItemToObject(json_buf, "TimingInfo", json_array);
    OSC_cJSON_AddNumberToObject(json_buf, "ErrorCode", 0);
}

Com_void Ext_IpcMqttClientPublish_PropertyPostFirst(Com_void)
{
    StIpcMqttComPublishInfo p_info;
    pStIpcMqttComCmdInfo cmd_data = Ext_Get_g_IpcMqttProperty_CmdData();

    memset(&p_info,0,sizeof(p_info));

    p_info.client = Ext_Get_g_IpcMqtt_Client();
    p_info.DevChn = 0;
    p_info.qos = QOS0;

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_POSTVERINFO].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    IpcMqttClientPublish_PropertyPostVerInfo(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_DEVINFO].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyDevInfo(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_NETINFO].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyNetInfo(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_DEVTIME].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyDevTime(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_VIDEOENCODE].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyVideoEncode(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_ISPPARAM].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyIspParam(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_RECORDCHN].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyRecordChn(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_OSDMODE].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyOSDMode(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_CUSTOMOSD].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyCustomOSD(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_GB28181PARAM].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyGB28181Param(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_CRUISEDATA].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyCruiseData(p_info.Data,1);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_POSTTFINFO].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    IpcMqttClientPublish_PropertyPostTFInfo(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);

    p_info.Cmd = cmd_data[IPC_MQTT_PROPERTY_TIMINGSNAPSHOT].mqtt_cmd;
    p_info.Data = OSC_cJSON_CreateObject();
    Ext_IpcMqttClientPublish_PropertyTimingSnapshot(p_info.Data);
    Ext_IpcMqttClientPublish_Msg(&p_info,IPC_MQTT_COM_TOPIC_PROPERTY_POST);


    // demo测试函数，实际使用时删除
    StIpcMqttPresetResult PresetResult;
    PresetResult.PresetPoints = 1;
    PresetResult.Result = 0;
    Ext_IpcMqttClientPublish_EventPresetResult(&PresetResult, 0);

    StIpcMqttCruiseResult CruiseResult;
    CruiseResult.Index = 1;
    CruiseResult.Result = 0;
    Ext_IpcMqttClientPublish_EventCruiseResult(&CruiseResult, 0);

    StIpcMqttPicResult PicResult;
    memset(&PicResult,0,sizeof(PicResult));
    PicResult.Type = 1;
    PicResult.PresetNum = 0;
    strcpy(PicResult.PicName,"20250801_115934.jpg");
    PicResult.Result = 0;
    Ext_IpcMqttClientPublish_EventPicResult(&PicResult, 0);

    StIpcMqttTFStatusResult TFStatusResult;
    TFStatusResult.TFCmd = 1;
    TFStatusResult.Result = 0;
    Ext_IpcMqttClientPublish_EventTFStatusResult(&TFStatusResult, 0);

    StIpcMqttOtaResult OtaResult;
    OtaResult.OtaType = 1;
    OtaResult.Result = 0;
    Ext_IpcMqttClientPublish_EventOtaResult(&OtaResult, 0);
}

// 事件
Com_void IpcMqttClientPublish_EventMsg(pStIpcMqttComPublishInfo p_info,Com_s32 type)
{
    pStIpcMqttComCmdInfo cmd_data = Ext_Get_g_IpcMqttEvent_CmdData();
    p_info->Cmd = cmd_data[type].mqtt_cmd;
    p_info->client = Ext_Get_g_IpcMqtt_Client();
    p_info->qos = QOS0;

    Ext_IpcMqttClientPublish_Msg(p_info,IPC_MQTT_COM_TOPIC_EVENT_POST);
}

Com_void Ext_IpcMqttClientPublish_EventPresetResult(pStIpcMqttPresetResult result,Com_s32 chn)
{
    StIpcMqttComPublishInfo p_info;

    memset(&p_info, 0, sizeof(p_info));

    p_info.DevChn = chn;
    p_info.Data = OSC_cJSON_CreateObject();
    OSC_cJSON_AddNumberToObject(p_info.Data, "PresetPoints", result->PresetPoints);
    OSC_cJSON_AddNumberToObject(p_info.Data, "Result", result->Result);
    IpcMqttClientPublish_EventMsg(&p_info,IPC_MQTT_EVENT_PRESETRESULT);
}

Com_void Ext_IpcMqttClientPublish_EventCruiseResult(pStIpcMqttCruiseResult result,Com_s32 chn)
{
    StIpcMqttComPublishInfo p_info;

    memset(&p_info, 0, sizeof(p_info));

    p_info.DevChn = chn;
    p_info.Data = OSC_cJSON_CreateObject();
    OSC_cJSON_AddNumberToObject(p_info.Data, "Index", result->Index);
    OSC_cJSON_AddNumberToObject(p_info.Data, "Result", result->Result);
    IpcMqttClientPublish_EventMsg(&p_info, IPC_MQTT_EVENT_CRUISERESULT);
}

Com_void Ext_IpcMqttClientPublish_EventPicResult(pStIpcMqttPicResult result,Com_s32 chn)
{
    StIpcMqttComPublishInfo p_info;

    memset(&p_info, 0, sizeof(p_info));

    p_info.DevChn = chn;
    p_info.Data = OSC_cJSON_CreateObject();
    OSC_cJSON_AddNumberToObject(p_info.Data, "Index", result->Type);
    OSC_cJSON_AddNumberToObject(p_info.Data, "PresetNum", result->PresetNum);
    OSC_cJSON_AddStringToObject(p_info.Data, "PicName", result->PicName);
    OSC_cJSON_AddNumberToObject(p_info.Data, "Result", result->Result);
    IpcMqttClientPublish_EventMsg(&p_info, IPC_MQTT_EVENT_PICRESULT);
}

Com_void Ext_IpcMqttClientPublish_EventTFStatusResult(pStIpcMqttTFStatusResult result,Com_s32 chn)
{
    StIpcMqttComPublishInfo p_info;

    memset(&p_info, 0, sizeof(p_info));

    p_info.DevChn = chn;
    p_info.Data = OSC_cJSON_CreateObject();
    OSC_cJSON_AddNumberToObject(p_info.Data, "TFCmd", result->TFCmd);
    OSC_cJSON_AddNumberToObject(p_info.Data, "Result", result->Result);
    IpcMqttClientPublish_EventMsg(&p_info, IPC_MQTT_EVENT_TFSTATUSRESULT);
}

Com_void Ext_IpcMqttClientPublish_EventOtaResult(pStIpcMqttOtaResult result,Com_s32 chn)
{
    StIpcMqttComPublishInfo p_info;

    memset(&p_info, 0, sizeof(p_info));

    p_info.DevChn = chn;
    p_info.Data = OSC_cJSON_CreateObject();
    OSC_cJSON_AddNumberToObject(p_info.Data, "OtaType", result->OtaType);
    OSC_cJSON_AddNumberToObject(p_info.Data, "Result", result->Result);
    IpcMqttClientPublish_EventMsg(&p_info, IPC_MQTT_EVENT_OTARESULT);
}
